home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 151-175 / disk_154 / ada / ada.l < prev    next >
Text File  |  1992-05-06  |  7KB  |  148 lines

  1. %{
  2. /*------------------------------------------------------------------------*/
  3. /* Lexical input for LEX for LALR(1) Grammar for ANSI Ada                 */
  4. /*                                                                        */
  5. /*              Herman Fischer                                            */
  6. /*            Litton Data Systems                                         */
  7. /*              March 26, 1984                                            */
  8. /*                                                                        */
  9. /* Accompanies Public Domain YACC format Ada grammar                      */
  10. /*                                                                        */
  11. /*                                                                        */
  12. /*                                                                        */
  13. /*                                                                        */
  14. /*                                                                        */
  15. /*                                                                        */
  16. /*                                                                        */
  17. /*------------------------------------------------------------------------*/
  18. /* #include        "y.tab.h"*/
  19. int             lines = 1;      /* line number being processed */
  20.  
  21. char id_string[256];            /* identifier being processed  */
  22. char char_lit[256];             /* character or string literal */
  23. char num_lit[80];               /* numeric literal             */
  24. int num_errors = 0;             /* number of errors encountered*/
  25.  
  26. #define linenum printf("\n[%d]\t",++lines)
  27. %}
  28.  
  29. %START IDENT Z
  30.  
  31. %%
  32. ABORT|abort     {ECHO; BEGIN Z; return(ABORT_);}
  33. ABS|abs         {ECHO; BEGIN Z; return(ABS_);}
  34. ACCEPT|accept   {ECHO; BEGIN Z; return(ACCEPT_);}
  35. ACCESS|access   {ECHO; BEGIN Z; return(ACCESS_);}
  36. ALL|all         {ECHO; BEGIN Z; return(ALL_);}
  37. AND|and         {ECHO; BEGIN Z; return(AND_);}
  38. ARRAY|array     {ECHO; BEGIN Z; return(ARRAY_);}
  39. AT|at           {ECHO; BEGIN Z; return(AT_);}
  40. BEGIN|begin     {ECHO; BEGIN Z; return(BEGIN_);}
  41. BODY|body       {ECHO; BEGIN Z; return(BODY_);}
  42. CASE|case       {ECHO; BEGIN Z; return(CASE_);}
  43. CONSTANT|constant {ECHO; BEGIN Z; return(CONSTANT_);}
  44. DECLARE|declare {ECHO; BEGIN Z; return(DECLARE_);}
  45. DELAY|delay     {ECHO; BEGIN Z; return(DELAY_);}
  46. DELTA|delta     {ECHO; BEGIN Z; return(DELTA_);}
  47. DIGITS|digits   {ECHO; BEGIN Z; return(DIGITS_);}
  48. DO|do           {ECHO; BEGIN Z; return(DO_);}
  49. ELSE|else       {ECHO; BEGIN Z; return(ELSE_);}
  50. ELSIF|elsif     {ECHO; BEGIN Z; return(ELSIF_);}
  51. END|end         {ECHO; BEGIN Z; return(END_);}
  52. ENTRY|entry     {ECHO; BEGIN Z; return(ENTRY_);}
  53. EXCEPTION|exception {ECHO; BEGIN Z; return(EXCEPTION_);}
  54. EXIT|exit       {ECHO; BEGIN Z; return(EXIT_);}
  55. FOR|for         {ECHO; BEGIN Z; return(FOR_);}
  56. FUNCTION|function {ECHO; BEGIN Z; return(FUNCTION_);}
  57. GENERIC|generic {ECHO; BEGIN Z; return(GENERIC_);}
  58. GOTO|goto       {ECHO; BEGIN Z; return(GOTO_);}
  59. IF|if           {ECHO; BEGIN Z; return(IF_);}
  60. IN|in           {ECHO; BEGIN Z; return(IN_);}
  61. IS|is           {ECHO; BEGIN Z; return(IS_);}
  62. LIMITED|limited {ECHO; BEGIN Z; return(LIMITED_);}
  63. LOOP|loop       {ECHO; BEGIN Z; return(LOOP_);}
  64. MOD|mod         {ECHO; BEGIN Z; return(MOD_);}
  65. NEW|new         {ECHO; BEGIN Z; return(NEW_);}
  66. NOT|not         {ECHO; BEGIN Z; return(NOT_);}
  67. NULL|null       {ECHO; BEGIN Z; return(NULL_);}
  68. OF|of           {ECHO; BEGIN Z; return(OF_);}
  69. OR|or           {ECHO; BEGIN Z; return(OR_);}
  70. OTHERS|others   {ECHO; BEGIN Z; return(OTHERS_);}
  71. OUT|out         {ECHO; BEGIN Z; return(OUT_);}
  72. PACKAGE|package {ECHO; BEGIN Z; return(PACKAGE_);}
  73. PRAGMA|pragma   {ECHO; BEGIN Z; return(PRAGMA_);}
  74. PRIVATE|private {ECHO; BEGIN Z; return(PRIVATE_);}
  75. PROCEDURE|procedure {ECHO; BEGIN Z; return(PROCEDURE_);}
  76. RAISE|raise     {ECHO; BEGIN Z; return(RAISE_);}
  77. RANGE|range     {ECHO; BEGIN Z; return(RANGE_);}
  78. RECORD|record   {ECHO; BEGIN Z; return(RECORD_);}
  79. REM|rem         {ECHO; BEGIN Z; return(REM_);}
  80. RENAMES|renames {ECHO; BEGIN Z; return(RENAMES_);}
  81. RETURN|return   {ECHO; BEGIN Z; return(RETURN_);}
  82. REVERSE|reverse {ECHO; BEGIN Z; return(REVERSE_);}
  83. SELECT|select   {ECHO; BEGIN Z; return(SELECT_);}
  84. SEPARATE|separate {ECHO; BEGIN Z; return(SEPARATE_);}
  85. SUBTYPE|subtype {ECHO; BEGIN Z; return(SUBTYPE_);}
  86. TASK|task       {ECHO; BEGIN Z; return(TASK_);}
  87. TERMINATE|terminate {ECHO; BEGIN Z; return(TERMINATE_);}
  88. THEN|then       {ECHO; BEGIN Z; return(THEN_);}
  89. TYPE|type       {ECHO; BEGIN Z; return(TYPE_);}
  90. USE|use         {ECHO; BEGIN Z; return(USE_);}
  91. WHEN|when       {ECHO; BEGIN Z; return(WHEN_);}
  92. WHILE|while     {ECHO; BEGIN Z; return(WHILE_);}
  93. WITH|with       {ECHO; BEGIN Z; return(WITH_);}
  94. XOR|xor         {ECHO; BEGIN Z; return(XOR_);}
  95. "=>"    {ECHO; BEGIN Z; return(ARROW_);}
  96. ".."    {ECHO; BEGIN Z; return(DBLDOT_);}
  97. "**"    {ECHO; BEGIN Z; return(EXP_);}
  98. ":="    {ECHO; BEGIN Z; return(ASSIGN_);}
  99. "/="    {ECHO; BEGIN Z; return(NOTEQL_);}
  100. ">="    {ECHO; BEGIN Z; return(GTEQL_);}
  101. "<="    {ECHO; BEGIN Z; return(LTEQ_);}
  102. "<<"    {ECHO; BEGIN Z; return(L_LBL_);}
  103. ">>"    {ECHO; BEGIN Z; return(R_LBL_);}
  104. "<>"    {ECHO; BEGIN Z; return(BOX_);}
  105. "&"     {ECHO; BEGIN Z; return('&'); }
  106. "("     {ECHO; BEGIN Z; return('('); }
  107. ")"     {ECHO; BEGIN IDENT; return(')'); }
  108. "*"     {ECHO; BEGIN Z; return('*'); }
  109. "+"     {ECHO; BEGIN Z; return('+'); }
  110. ","     {ECHO; BEGIN Z; return(','); }
  111. "-"     {ECHO; BEGIN Z; return('-'); }
  112. "."     {ECHO; BEGIN Z; return('.'); }
  113. "/"     {ECHO; BEGIN Z; return('/'); }
  114. ":"     {ECHO; BEGIN Z; return(':'); }
  115. ";"     {ECHO; BEGIN Z; return(';'); }
  116. "<"     {ECHO; BEGIN Z; return('<'); }
  117. "="     {ECHO; BEGIN Z; return('='); }
  118. ">"     {ECHO; BEGIN Z; return('>'); }
  119. "|"     {ECHO; BEGIN Z; return('|'); }
  120. <IDENT>\'  {ECHO; BEGIN Z; return('\'');}   /* type mark only */
  121.  
  122.  
  123. [a-zA-Z]([_]?[a-zA-Z0-9])*   {ECHO; BEGIN IDENT; strcpy(id_string,yytext);
  124.                               return(identifier);}
  125. [0-9][0-9_]*([.][0-9_]+)?([Ee][-+]?[0-9_]+)?  {
  126.                               ECHO; BEGIN Z; strcpy(num_lit,yytext);
  127.                               return(numeric_literal);}
  128.  
  129. [0-9][0-9_]*#[0-9a-fA-F_]+([.][0-9a-fA-F_]+)?#([Ee][-+]?[0-9_]+)? {
  130.                               ECHO; BEGIN Z; strcpy(num_lit,yytext);
  131.                               return(numeric_literal);}
  132.  
  133.  
  134. \"([^"]*(\"\")*)*\" {ECHO; BEGIN Z; strcpy(char_lit,yytext);
  135.                           return(string_literal);}
  136. <Z>\'.\'    {ECHO; BEGIN Z; strcpy(char_lit,yytext);
  137.                           return(character_literal);}
  138.  
  139.  
  140. [ \t]   ECHO;          /* ignore spaces and tabs */
  141. "--".*  ECHO;          /* ignore comments to end-of-line */
  142.  
  143. .       {ECHO; printf("?? lexical error [%s] ??\n\t", yytext);
  144.                                            /* unlexable chars */
  145.         ++num_errors;}
  146. [\n]    linenum;
  147. %%
  148.